public class Main {
    public String solve (String s, String t) {
        if(s.equals("")||s==null) return t;
        if(t.equals("")||t==null) return s;
        int sum=0,count=0,sSum=0,tSum=0;
        char[] arr1=s.toCharArray();
        char[] arr2=t.toCharArray();
        StringBuffer sb=new StringBuffer();
        reserve(arr1);
        reserve(arr2);
        for(int i=0;i<arr1.length||i<arr2.length;i++){
            if(i<arr1.length) sSum=arr1[i]-'0';
            else sSum=0;
            if(i<arr2.length) tSum=arr2[i]-'0';
            else tSum=0;
            sum=sSum+tSum+count;
            count=sum/10;
            sb.append((char)(sum%10+'0'));
        }
        if(count>0) sb.append((char)(count+'0'));
        return sb.reverse().toString();
    }
    public void reserve(char[] arr){
        int left=0,right=arr.length-1;
        while(left<right){
            char a=arr[left];
            arr[left]=arr[right];
            arr[right]=a;
            left++;
            right--;
        }
    }
    public ListNode addInList (ListNode head1, ListNode head2) {
        head1=reverse(head1);
        head2=reverse(head2);
        ListNode head3=new ListNode(-1);
        ListNode p=head3;
        int ca=0,sum1=0,sum2=0,sum=0;
        while(head1!=null||head2!=null){
            if(head1!=null) {
                sum1=head1.val;
                head1=head1.next;
            }
            else sum1=0;
            if(head2!=null) {
                sum2=head2.val;
                head2=head2.next;
            }
            else sum2=0;
            sum=sum1+sum2+ca;
            ca=sum/10;
            p.next=new ListNode(sum%10);
            p=p.next;
        }
        if(ca!=0) p.next=new ListNode(ca);
        p=head3.next;
        return reverse(p);
    }
    private ListNode reverse(ListNode head) {
        if (head == null) return null;
        ListNode pre = null;
        ListNode cur = head;
        while (cur != null) {
            ListNode pNext = cur.next;
            cur.next = pre;
            pre = cur;
            cur = pNext;
        }
        return pre;
    }
    class ListNode {
        int val;
        ListNode next = null;
        public ListNode(int val) {
          this.val = val;
        }
      }
}